#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QHash>
#include <QLabel>
#include <QGroupBox>
#include <QLineEdit>
#include <QPushButton>
#include <QProgressBar>
#include <QtGui/QMainWindow>

#include <qextserialbase.h>
#include <qextserialport.h>

#include "texmetercomm.h"
#include "texmoduleregistereditor.h"

namespace Ui
{
    class MainWindowClass;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = 0);
    ~MainWindow();

protected:
    void closeEvent(QCloseEvent *event);

private:
    Ui::MainWindowClass *ui;
    union eepromRegister {
        float f;
        INT32 i;
        byte b[4];
    };
    eepromRegister smartModule[4][1024];
    eepromRegister internalModule[1024];

    ulong serialPortTimeout;
    texMeterComm *serialPort;
    
    QTabWidget *tabWidget;
    texModuleRegisterEditor *module[4];

    void setupSignals();
    void setupRegisterTabs();
    void readSettings();
    void writeSettings();

private slots:
    void fileLoad();
    void fileSave();
    void dataChanged();
    bool readMeter();
    bool programMeter();
};

#endif // MAINWINDOW_H
